package com.woldier.check.config;

import com.woldier.check.common.R;
import com.woldier.check.common.exception.BizException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.HttpClientErrorException;

import java.rmi.RemoteException;
@ControllerAdvice
@Slf4j
public class GlobalExceptionHandler {


    /**
     * remote异常处理
     * @param e
     * @return
     */
    @ExceptionHandler(HttpClientErrorException.class)
    @ResponseBody
    public R remoteExceptionHandler(Exception e){
        log.error(e.getMessage());
        return R.error(e.getMessage());
    }

    @ExceptionHandler(BizException.class)
    @ResponseBody
    public R BizExceptionHandler(BizException e){
        return R.error(e.getMsg());
    }


}
